const router = require('koa-router')()
const areas = require('../models/areas.js')

router.prefix('/api/areas')

router.get('/', async (ctx, next) => {
  ctx.body = await areas.getAreas()
})

router.post('/', async (ctx, next) => {
  ctx.body = await areas.addArea()
})

router.put('/', async (ctx, next) => {
  ctx.body = await areas.updateArea()
})

router.delete('/', async (ctx, next) => {
  ctx.body =  await areas.delArea()
})

module.exports = router
